<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui-mobile/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui-mobile/themes/mobile.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui-mobile/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui-mobile/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui-mobile/jquery.easyui.mobile.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui-mobile/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/js/common.js"/>"></script>


<script type="text/javascript">

	
    function initList(listDisplayEId) {
		$('#' + listDisplayEId).datagrid({
			url:"<c:url value="/distributorForSup/findDistributorOrderForSup.do"/>"
		});
    };
    $(document).ready(function() {
    	
    	$('#ordDate').datebox({
    		width:"100px",
            onSelect : function(date) {
                searchInfo();
            }
        });
    	
        initList('dg');
    });
    function searchInfo(){
    	var date = $('#ordDate').datebox('getValue');
            $('#dg').datagrid('reload', {
                ordDate:date
            }); 
            
    }

    	
	var editIndex = undefined;
	function endEditing() {
		if (editIndex == undefined) {
			return true
		}
		if ($('#dg').datagrid('validateRow', editIndex)) {
			$('#dg').datagrid('endEdit', editIndex);
			editIndex = undefined;
			return true;
		} else {
			return false;
		}
	}
	function onClickRow(index) {
		if (editIndex != index) {
			if (endEditing()) {
				$('#dg').datagrid('selectRow', index).datagrid('beginEdit',
						index);
				editIndex = index;
			} else {
				$('#dg').datagrid('selectRow', editIndex);
			}
		}
	}
	function removeit() {
		if (editIndex == undefined) {
			return
		}
		$('#dg').datagrid('cancelEdit', editIndex).datagrid('deleteRow',
				editIndex);
		editIndex = undefined;
	}
	function accept() {
		if (endEditing()) {
			$('#dg').datagrid('acceptChanges');
		}
	}
	function detail() {
		var row = $('#dg').datagrid('getSelections');      
        if(row.length == 0){
            $.messager.alert('提示','请选择一条记录操作！','info');
            return;
        } else {
            window.location.href="<c:url value='/jsp/openIndexSun.jsp?url=/distributorForSup/goDistributorDetailedForSup.do'/>"+"?id="+row[0]['ordId']+"&ordDistributorId="+row[0]['ordDistributorId']+"&flag=false";
        }
		
	}
</script>
<body>
	<table id="dg" 
		data-options="
                header:'#hh',
                iconCls: 'icon-edit',
                singleSelect: true,
                fit:true,
                nowrap : false,
                fitColumns:true,
                border: false,
                scrollbarSize: 0,
                pagination:true, pageSize:10,
                onClickRow: onClickRow,
                idField:'ordId'
            ">
		<thead>
			<tr>
				<th data-options="field:'ordId',width:60">订单号</th>
				<th data-options="field:'ordSupId',hidden:true">供货商id</th>
				<th data-options="field:'ordDistributorId',hidden:true">分销商id</th>
				<th data-options="field:'ordDisName',width:80">分销商</th>
				<th data-options="field:'ordStateDistributor',width:80,formatter:formatOrdStateDistributor">订单状态</th>
				<th data-options="field:'orderDate',width:80">订单日期</th>
				<th data-options="field:'orderDay',width:80">订单日</th>
				<th data-options="field:'ordValue',width:80">总价</th>
			</tr>
		</thead>
	</table>
	<div id="hh">
		<div class="m-toolbar">
			<!--             <div class="m-title">Row Editing</div> 
 -->
			<div class="m-left">
				<li style="line-height: 32px; font-size: 16px; font-weight: bold;">
					订单日 &nbsp;&nbsp;<input class="easyui-datebox" editable="false"
					id="ordDate" name="ordDate" ></input>
				</li>
			</div>
			<div class="m-right">
				
				<a href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true" onclick="detail()">详细订单</a>

			</div>
		</div>
	</div>

</body>
</html>